import { aesEncode } from '@/utils/handle-crypto';
import request from '@/utils/request';

export function login(body: API.LoginParams) {
  return request<API.LoginResult>('/api/sys-users/v1.0.0/signIn', {
    method: 'POST',
    data: { data: aesEncode(body) },
  });
}

export function queryCurrentUser() {
  return request<API.CurrentUser>('/api/sys-users/v1.0.0/currentUser');
}

export async function logout() {
  await request('/api/sys-users/v1.0.0/logout', {
    method: 'POST',
  });
}

export async function wechatLog(code: string) {
  return request('/api/sys-users/v1.0.0/wx/open', {
    method: 'POST',
    data: { code },
  });
}

export async function wechatSelectLogin(userid: string) {
  return request('/api/sys-users/v1.0.0/wx/select/login', {
    method: 'POST',
    data: { userid },
  });
}
